﻿namespace RialternativeSample.Tests.Client.ViewModels
{
    using System.Linq;
    using Microsoft.Practices.Unity;
    using Microsoft.Silverlight.Testing;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using RialternativeSample.Client.Helpers;
    using RialternativeSample.Server.NorthwindService;
    using RialternativeSample.Tests.Client.Mocks;
    using RialternativeSample.ViewModels;
    using RialternativeSample.ViewModels.Interfaces;

    [TestClass]
    public class CustomersViewModelTest : SilverlightTest
    {
        [TestInitialize]
        public void Initialize()
        {
            Bootstrapper.Configure();
            UnityHelper.UnityContainer.RegisterType<NorthwindContext>(new InjectionConstructor(new NorthwindMockDomainClient()));
        }

        [TestMethod]
        [Asynchronous]
        public void CanLoadCustomersTest()
        {
            CustomersViewModel customersViewModel = null;
            EnqueueCallback(() => customersViewModel = (CustomersViewModel)UnityHelper.UnityContainer.Resolve<ICustomersViewModel>());
            EnqueueCallback(() => Assert.IsTrue(customersViewModel.Customers.Any()));
            EnqueueTestComplete();
        }
    }
}
